﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using DeSleeper.Client.Properties;
using DeSleeper.Client.WakeUp;
using MbUnit.Framework;

namespace DeSleeper.Tests
{
    [TestFixture]
    public class WakeUpDestinationFixture
    {
        [Test]
        public void SerializeDestinations()
        {
            var destinations = new List<WakeUpDestination>();
            var expected = new ProxyWakeUpDestination { ProxyAddress = "TestAddress" };
            destinations.Add(expected);
            var serializer = new XmlSerializer(typeof(List<WakeUpDestination>));

            using (var writer = new StringWriter())
            {
                serializer.Serialize(writer, destinations);
                Console.WriteLine(writer.GetStringBuilder().ToString());
                using (var reader = new StringReader(writer.GetStringBuilder().ToString()))
                {
                    var outputDestination = serializer.Deserialize(reader) as List<WakeUpDestination>;
                    var output = outputDestination.First() as ProxyWakeUpDestination;
                    Assert.AreEqual(expected.ProxyAddress, output.ProxyAddress);
                }
            }
        }
    }
}
